<?php
declare (strict_types = 1);

namespace app\api\controller\v1;

use app\api\controller\Base;
use app\api\model\ProjectLockPerformanceClass;
use app\api\model\ProjectLockReviewResult;
use app\api\model\ProjectPerformanceClass;
use app\api\model\ProjectPerformanceContent;
use app\api\model\ProjectPerformanceSpot;
use think\facade\Db;
use think\facade\Queue;
use app\api\model\ProjectInfo as ProjectInfoModel;
use app\api\model\ProjectPerOrg as ProjectPerOrgModel;
use app\api\model\ProjectReviewResult as ProjectReviewResultModel;
use app\api\model\ProjectPerOrgPeople as ProjectPerOrgPeopleModel;
use app\api\model\ProjectLockReviewResult as ProjectLockReviewResultModel;
use app\api\model\ProjectLockPerformanceClass as ProjectLockPerformanceClassModel;
use app\api\model\ProjectLockPerformanceContent as ProjectLockPerformanceContentModel;
use app\api\model\ProjectLockPerformanceSpot as ProjectLockPerformanceSpotModel;
use app\api\model\ProjectLockPerOrg as ProjectLockPerOrgModel;
use app\api\model\ProjectPerformance as ProjectPerformanceModel;
use app\api\model\ProjectLockReviewResult as ProjectReviewLockResultModel;
use app\api\model\ProjectLockPerOrgPeople as ProjectLockPerOrgPeopleModel;
use app\api\model\ProjectTeamScore as ProjectTeamScoreModel;
use app\api\model\ProjectPerOrg;
use app\Request;

class Task extends Base
{

    /**
     * 定时任务测试函数
     * @param Request $request
     * @return string|\think\response\Json
     */
    public function test(Request $request)
    {
        try {

            $jobHander = '\app\api\controller\v1\Hello@fire';
            $jobData = ['ts' => time()];
            $jobQueueName  	  = "helloJobQueue";
            Queue::later(2, $jobHander, $jobData,$jobQueueName);
            return "success";

        } catch (\Exception $e) {
            $error = ["status"=>false,"msg"=>$e->getMessage(),"code"=>$e->getCode()];
            return json($error);
        }
    }
    /**
     * 评审提醒推送
     * @param Request $request
     * @return \think\response\Json
     */
    public function sendReviewMsg(Request $request)
    {
        try {

            //获取所有项目
            $ProjectInfoModel =  new ProjectInfoModel();
            $list = $ProjectInfoModel->select();
            $jobHander = '\app\api\controller\v1\ProjectTask@fire';
            $jobQueueName  	  = "sendReviewMsgQueue";

            //循环写入队列，队列去处理查询
            foreach ($list as $v){
                $v['time'] = date("Y-m-d H:i:s");
                $jobData = $v;
                //Queue::later(2, $jobHander, $jobData,$jobQueueName);
                Queue::push( $jobHander, $jobData,$jobQueueName);
            }
            return "success";

        } catch (\Exception $e) {
            $error = ["status"=>false,"msg"=>$e->getMessage(),"code"=>$e->getCode()];
            return json($error);
        }
    }

    /**
     * 考核单生成
     * @param Request $request
     * @return \think\response\Json
     */
    public function createReviewResult(Request $request){
        try {
            //查询考核关系，生成考核单
            $month = $request->param('month');
            $month = strtotime(date('Y-m',strtotime($month)));
            //$month = strtotime(date('Y-m',time()));
            //先查询当前月份是否已经生成
            $ProjectReviewResultModel = new ProjectReviewResultModel();
            $i = $ProjectReviewResultModel->where('month','like',$month)->find();
            if($i!=null){
                $error = ["status"=>false,"msg"=>"已经生成过数据，请不要重复生成!"];
                return json($error);
            }else{
                $this->createReviewResultIteraction(0,$month);
                $error = ["status"=>true,"msg"=>"操作执行成功!"];
                return json($error);
            }

        } catch (\Exception $e) {
            $error = ["status"=>false,"msg"=>$e->getMessage(),"code"=>$e->getCode()];
            return json($error);
        }
    }

    /**
     * 自动处理项目经理的分
     * @param Request $request
     * @return \think\response\Json
     */
    public function getProjectOrProjectPmScore(Request $request){
        try {

            $month = $request->param('month');
            if($month){
                 $month = strtotime(date('Y-m',strtotime($month)));
            }else{
                 $month = strtotime(date('Y-m',time()));
            }
            
            //查询项目所有项目经理并计算总分
            $ProjectInfoModel = new ProjectInfoModel();
            $projectInfo = $ProjectInfoModel->alias('p')
                ->field('GROUP_CONCAT(`p`.`project_name`) as project_group,p.project_pm,
                GROUP_CONCAT(`p`.`project_level`) as project_level,
                SUM(l.score) as project_total_score,
                op.id as peop_id,op.name,
                rw.id')
                ->join('project_per_org_people op','p.project_pm = op.uid')
                ->leftjoin('project_level l','p.project_level = l.name')
                ->leftjoin('project_review_result rw','op.id = rw.uid')
                ->group('p.project_pm')
                ->where('p.is_check','=','1')
                ->where('op.is_outer','=',0)
                ->where('rw.month','=',$month)
                ->where('rw.spot_id','=','92')
                ->order('project_total_score')->select();
            $sql = $ProjectInfoModel->getLastSql();
            //项目经理所有项目加起来的分超过了6分的，就重置为6
            $reviewResult = [];
            foreach ($projectInfo as $k=>$vo){
                if($vo['project_total_score']>6) $vo['project_total_score'] = "6.0";
                $reviewResult[$k]['id'] = $vo['id'];
                $reviewResult[$k]['score'] = $vo['project_total_score'];
            }
            if($reviewResult) $reviewResult = $reviewResult;
            //批量更新考核项目的分数
            $ProjectReviewResultModel = new ProjectReviewResultModel();
            $i = $ProjectReviewResultModel->saveAll($reviewResult);
            $sql1 = $ProjectReviewResultModel->getLastSql();
            if($i!==false){
                $error = ["status"=>false,"msg"=>"已更新","sql"=>$sql,"sql1"=>$sql1];
                return json($error);
            }else{
                $this->createReviewResultIteraction(0,$month);
                $error = ["status"=>true,"msg"=>"更新失败!"];
                return json($error);
            }

        } catch (\Exception $e) {
            $error = ["status"=>false,"msg"=>$e->getMessage(),"code"=>$e->getCode()];
            return json($error);
        }
    }

    /**
     * 自动处理项目成员的分
     * @param Request $request
     * @return \think\response\Json
     */
    public function getProjectOrProjectTeamScore(Request $request){
        try {

            //$month = $request->param('month');
            $month_f = date('Y-m',time());
            $month = strtotime($month_f);
            //查询项目所有项目成员并计算分
            $ProjectTeamScoreModel = new ProjectTeamScoreModel();
            $projectInfo = $ProjectTeamScoreModel->alias('ts')
                ->field('t.zn_name,rw.spot_id,rw.id,SUM(ts.score)')
                ->leftjoin('project_info p','ts.project_id = p.id')
                ->leftjoin('project_teaminfo t','ts.uid = t.uid  and  ts.project_id = t.project_id')
                ->leftjoin('project_per_org_people op','t.uid = op.uid')
                ->leftjoin('project_review_result rw','op.id = rw.uid')
                ->where('ts.month','=',$month)
                ->where('rw.month','=',$month)
                ->where('rw.spot_id','=','206')
                ->where('t.status','=','1')
                ->order('p.id')
                ->group('ts.uid')
                ->select();
            $sql = $ProjectTeamScoreModel->getLastSql();

            if(false){
                $error = ["status"=>false,"msg"=>"已更新"];
                return json($error);
            }else{
                $this->createReviewResultIteraction(0,$month);
                $error = ["status"=>true,"msg"=>"更新失败!"];
                return json($error);
            }

        } catch (\Exception $e) {
            $error = ["status"=>false,"msg"=>$e->getMessage(),"code"=>$e->getCode()];
            return json($error);
        }
    }
    /**
     * 迭代生成考核单
     * @param $orgid
     * @return \think\response\Json
     */
    private  function  createReviewResultIteraction($orgid=0,$month=""){
        try {
            //查询考核关系，生成考核单
            $ProjectPerOrgModel = new ProjectPerOrgModel;
            $orglist = $ProjectPerOrgModel->where('pid','=',$orgid)->select()->toArray();
            foreach ($orglist as $vo){
                //组织下的人
                $ProjectPerOrgPeopleModel =  new ProjectPerOrgPeopleModel;
                $userlist = $ProjectPerOrgPeopleModel->where('orgid','=',$vo['id'])
                                                     ->where('is_outer','=',0)
                                                     ->where('is_reiviewed','=',1)
                                                     ->select()->toArray();
                foreach ($userlist as $v){
                    //查询分类
                    $ProjectPerformanceClass = new ProjectPerformanceClass;
                    $performanceclasslist = $ProjectPerformanceClass->select()->toArray();
                    //查询所有的考核点
                    $ProjectPerformanceSpotModel = new ProjectPerformanceSpot();

                    $spotlist = [];
                    foreach ($performanceclasslist as $class_v){
                        $key = $class_v['id'];
                        $spotlist[$key] = $ProjectPerformanceSpotModel->where('class_id','=',$class_v['id'])
                            ->where('status','=',1)
                            ->where('pid','<>',0)->select()->toArray();
                    }
                    //根据当前人查询组织的考核人,分为日常考核和质量考核 kp=1,2
                    $data = [];
                    foreach ($spotlist as $k=>$m){

                        foreach ($m as $m_v){
                            $tmp = [];
                            $tmp['spot_id'] = $m_v['id'];
                            $tmp['uid'] = $v['id'];
                            $tmp['month'] = $month;
                            $tmp['org_id'] = $vo['id'];
                            $tmp['status'] = 1;
                            $tmp['class_id'] = $k;
                            $tmp['create_time'] = time();
                            $data[] = $tmp;
                        }

                    }
                    $ProjectReviewResultModel = new ProjectReviewResultModel();
                    $ProjectReviewResultModel->insertAll($data);
                }
                $this->createReviewResultIteraction($vo['id'],$month);
            }

        } catch (\Exception $e) {
            $error = ["status"=>false,"msg"=>$e->getMessage(),"code"=>$e->getCode()];
            return json($error);
        }
    }

    /**
     * 锁定考核
     * @param Request $request
     * @return \think\response\Json
     */
    public function  mlockReivewResult(Request $request){
        try {

              Db::startTrans();
              $month = $request->param('month');
              $monthR = strtotime(date('Y-m',strtotime($month)));
              $ProjectReviewResultModel = new ProjectReviewResultModel();
              $reviewResult = $ProjectReviewResultModel->where('month','like',$monthR)->count();
              $ProjectLockReviewResultModel = new ProjectLockReviewResultModel();
              $lockReviewResult = $ProjectLockReviewResultModel->where('month','like',$monthR)->count();
              if(!$reviewResult){
                  Db::rollback();
                  $result = ["status"=>false,"msg"=>"无可以锁定的数据！"];
                  return json($result);
              }
              if($lockReviewResult){
                  Db::rollback();
                  $result = ["status"=>false,"msg"=>"已锁定过，请不要重复锁定！"];
                  return json($result);
              }

              $res  = $this->lockPerOrg($month);
              $res1 = $this->lockPerOrgPeople($month);
              $res2 = $this->lockPerformanceClass($month);
              $res3 = $this->lockPerFormanceContent($month);
              $res4 = $this->lockPerFormanceSpot($month);
              $res5 = $this->lockReviewResult($month);

              if($res['status']&&$res1['status']&&$res2['status']&&$res3['status']&&$res4['status']&&$res5['status']){
                  //重置月度考核成绩表lock字段
                  $monthF = date('Y-m',strtotime($month));
                  $ProjectPerformanceModel = new ProjectPerformanceModel();
                  $f_data['lock'] = 1;
                  $ProjectPerformanceModel->where('month','like',$monthF)->save($f_data);
                  $this->createDepartBaseScore($month);
                  Db::commit();
                  $result = ["status"=>true,"msg"=>"锁定成功！"];
              }else{
                  Db::rollback();
                  $result = ["status"=>false,"msg"=>"锁定失败！"];
//                  if (!$res['status']) $result = ["status"=>false,"msg"=>"锁定失败！".$res['msg']];
//                  if (!$res1['status']) $result = ["status"=>false,"msg"=>"锁定失败！".$res1['msg']];
//                  if (!$res2['status']) $result = ["status"=>false,"msg"=>"锁定失败！".$res2['msg']];
//                  if (!$res3['status']) $result = ["status"=>false,"msg"=>"锁定失败！".$res3['msg']];
//                  if (!$res4['status']) $result = ["status"=>false,"msg"=>"锁定失败！".$res4['msg']];
//                  if (!$res5['status']) $result = ["status"=>false,"msg"=>"锁定失败！".$res5['msg']];
                  if (!$res['status']) $result = ["status"=>false,"msg"=>"锁定失败！"."lockPerOrg:".$res['msg']];
                  if (!$res1['status']) $result = ["status"=>false,"msg"=>"锁定失败！"."lockPerOrgPeople:".$res1['msg']];
                  if (!$res2['status']) $result = ["status"=>false,"msg"=>"锁定失败！"."lockPerformanceClass:".$res2['msg']];
                  if (!$res3['status']) $result = ["status"=>false,"msg"=>"锁定失败！"."lockPerFormanceContent:".$res3['msg']];
                  if (!$res4['status']) $result = ["status"=>false,"msg"=>"锁定失败！"."lockPerFormanceSpot:".$res4['msg']];
                  if (!$res5['status']) $result = ["status"=>false,"msg"=>"锁定失败！"."lockReviewResult:".$res5['msg']];
              }
              return json($result);

        } catch (\Exception $e) {
            $error = ["status"=>false,"msg"=>$e->getMessage(),"code"=>$e->getCode()];
            return json($error);
        }
    }

    /**
     * 创建部门基准分
     * @param $month
     * @return array
     */
    public function createDepartBaseScore($month){
        try{

            $month = strtotime($month);
            $ProjectReviewResultModel = new ProjectReviewLockResultModel();
            $ProjectPerformanceClassModel = new ProjectPerformanceClass();
            $ProjectPerformanceSpotModel = new ProjectPerformanceSpot();
            $ProjectPerformanceModel = new ProjectPerformanceModel();
            $ProjectPerOrgModel = new ProjectPerOrgModel();
            $departArr = $ProjectPerOrgModel->where('depart_spot','=',1)
                ->where('id','<>',3)
                ->select()->toArray();

            foreach($departArr as $vo){
                $orgArr = $ProjectPerOrgModel->where('pid','=',$vo['id'])->select()->toArray();
                $orgStr = "";
                foreach($orgArr as $k=>$v){
                    $orgStr = $v['id'].','.$orgStr;
                }
                $orgStrTrim = rtrim($orgStr,',');

                $weight_quality = $ProjectPerformanceClassModel->where('id','=',2)->find()->toArray(); //取质量分类得权重
                $spot_quality = $ProjectPerformanceSpotModel->where('weight','>',0)->select()->toArray();//取考核标准得权重，有权重值的，按照权重值算出来的分数，加到总分里边
                $spot_quality_arr = "";
                foreach ($spot_quality as $v){
                    $spot_quality_arr = $spot_quality_arr.$v['id'].',';
                }
                $spot_quality_arr = rtrim($spot_quality_arr, ",");
                $reviewResultList_quality = $ProjectReviewResultModel->alias('rw')
                    ->field('p.name,rw.uid,((sum(rw.score*100)/100+100)*'.($weight_quality["weight"]/100).') as total_score')
                    ->join('ProjectPerOrgPeople p','rw.uid = p.id')
                    ->where('org_id','IN',$orgStrTrim)
                    ->where('rw.month','=',$month)
                    ->where('spot_id','NOT IN',"$spot_quality_arr")
                    ->where('class_id','=',2)
                    ->group('rw.uid')
                    ->select()->toArray(); //不包括考核标准设置了权重值的

                $sql = $ProjectReviewResultModel->getLastSql();

                $reviewResultList_weight_quality= $ProjectReviewResultModel->alias('rw')
                    ->field('p.name,rw.uid,(sum(rw.score*100*(weight/100))/100) as total_score')
                    ->join('ProjectPerOrgPeople p','rw.uid = p.id')
                    ->join('project_performance_spot s','rw.spot_id = s.id')
                    ->where('org_id','IN',$orgStrTrim)
                    ->where('rw.month','=',$month)
                    ->where('spot_id','IN',"$spot_quality_arr")
                    ->where('rw.class_id','=',2)
                    ->group('rw.uid')
                    ->select()->toArray(); //只包含考核标准设置了权重值的

                $sql = $ProjectReviewResultModel->getLastSql();

                $weight_normal = $ProjectPerformanceClassModel->where('id','=',1)->find()->toArray();
                $reviewResultList_normal = $ProjectReviewResultModel->alias('rw')
                    ->field('p.name,p.uid,(sum(rw.score*100)*'.($weight_normal["weight"]/100).'/100) as total_score')
                    ->join('ProjectPerOrgPeople p','rw.uid = p.id')
                    ->where('org_id','IN',$orgStrTrim)
                    ->where('rw.month','=',$month)
                    ->where('class_id','=',1)
                    ->group('rw.uid')
                    ->select()->toArray(); //不包括考核标准设置了权重值的

                if($reviewResultList_normal){

                    //把质量分加入到日常分里去
                    $i=0;
                    foreach($reviewResultList_normal as $key=>$vo){

                        foreach ($reviewResultList_quality as $k=>$v){
                            if($v['uid'] == $vo['uid']){
                                $reviewResultList_normal[$i]['total_score'] =($reviewResultList_normal[$i]['total_score']*100+$v['total_score']*100)/100;
                            }
                        }
                        $i++;

                    }

                    //把附加分加进去
                    $i=0;
                    foreach($reviewResultList_normal as $key=>$vo){

                        foreach ($reviewResultList_weight_quality as $k=>$v){
                            if($v['uid'] == $vo['uid']){
                                $reviewResultList_normal[$i]['total_score'] = ($reviewResultList_normal[$i]['total_score']*100+$v['total_score']*100)/100;
                            }
                        }
                        $i++;

                    }


                }
                if($reviewResultList_normal)
                    $reviewResultList_normal_result = arraySort($reviewResultList_normal, 'total_score', SORT_DESC);

                //计算总分
                $t_score = 0;
                $t_num = count($reviewResultList_normal_result);
                foreach($reviewResultList_normal_result as $rv){
                    $t_score = ($t_score*100+$rv['total_score']*100)/100;
                }
                //计算基准分
                $i = 0;
                foreach($reviewResultList_normal_result as $rvo){
                    $reviewResultList_normal_result[$i]['create_time'] = date("Y-m-d H:i",time()) ;
                    $reviewResultList_normal_result[$i]['month'] = date("Y-m",$month);
                    $reviewResultList_normal_result[$i]['avg_score'] = round($t_score/$t_num,2);
                    $i++;
                }
                $ProjectPerformanceModel->insertAll($reviewResultList_normal_result);
            }
            //return json($reviewResultList_normal_result);

        } catch (\Exception $e) {
            $error = ["status"=>false,"msg"=>$e->getMessage(),"code"=>$e->getCode()];
            return $error;
        }
    }
    /**
     * 锁考核记录
     * @param $month
     * @return array
     */
    private function lockReviewResult($month){
        try {
            $month = strtotime(date('Y-m',strtotime($month)));
            $ProjectReviewResultModel = new ProjectReviewResultModel();
            $reviewResult = $ProjectReviewResultModel->where('month','like',$month)->select();
            $ProjectLockReviewResult = new ProjectLockReviewResultModel();
            if($reviewResult){
                $data = $reviewResult->toArray();
                foreach($data as $k=>$v){
                    $data[$k]['month'] = $month;
                    if($v['update_time'])  $data[$k]['update_time'] = strtotime($v['update_time']);
                    else $data[$k]['update_time'] = "0";
                    if($v['create_time'])  $data[$k]['create_time'] = strtotime($v['create_time']);
                    else $data[$k]['create_time'] = "0";
                }
                $res = $ProjectLockReviewResult->insertAll($data);
                $error = ["status"=>true,"msg"=>"操作成功"];
                return $error;
            }else{
                $error = ["status"=>false,"msg"=>"操作失败"];
                return $error;
            }
        } catch (\Exception $e) {
            $error = ["status"=>false,"msg"=>$e->getMessage(),"code"=>$e->getCode()];
            return $error;
        }
    }
    /**
     * 锁组织
     * @param $month
     * @return array
     */
    private function  lockPerOrg($month){
        try {
            $month = strtotime(date('Y-m',strtotime($month)));
            $ProjectPerOrgModel = new ProjectPerOrgModel();
            $orgData = $ProjectPerOrgModel->select();
            $ProjectLockPerOrgModel = new ProjectLockPerOrgModel();
            if($orgData){
                $data = $orgData->toArray();
                foreach($data as $k=>$v){
                    $data[$k]['month'] = $month;
                    if($v['update_time'])  $data[$k]['update_time'] = strtotime($v['update_time']);
                    else $data[$k]['update_time'] = "0";
                    if($v['create_time'])  $data[$k]['create_time'] = strtotime($v['create_time']);
                    else $data[$k]['create_time'] = "0";
                }
                $res = $ProjectLockPerOrgModel->insertAll($data);
                $error = ["status"=>true,"msg"=>"操作成功"];
                return $error;
            }else{
                $error = ["status"=>false,"msg"=>"操作失败"];
                return $error;
            }
        } catch (\Exception $e) {
            $error = ["status"=>false,"msg"=>$e->getMessage(),"code"=>$e->getCode()];
            return $error;
        }
    }

    /**
     * 锁组织人员
     * @param $month
     * @return array
     */
    private function  lockPerOrgPeople($month){
        try {
            $month = strtotime(date('Y-m',strtotime($month)));
            $ProjectPerOrgPeopleModel     = new ProjectPerOrgPeopleModel();
            $pData = $ProjectPerOrgPeopleModel->select();
            $ProjectLockPerOrgPeopleModel = new ProjectLockPerOrgPeopleModel();
            if($pData){
                $data = $pData->toArray();
                foreach($data as $k=>$v){
                    $data[$k]['month'] = $month;
                    if($v['update_time'])  $data[$k]['update_time'] = strtotime($v['update_time']);
                    else $data[$k]['update_time'] = "0";
                    if($v['create_time'])  $data[$k]['create_time'] = strtotime($v['create_time']);
                    else $data[$k]['create_time'] = "0";
                }
                $res = $ProjectLockPerOrgPeopleModel->insertAll($data);
                $error = ["status"=>true,"msg"=>"操作成功"];
                return $error;
            }else{
                $error = ["status"=>false,"msg"=>"操作失败"];
                return $error;
            }
        } catch (\Exception $e) {
            $error = ["status"=>false,"msg"=>$e->getMessage(),"code"=>$e->getCode()];
            return $error;
        }
    }

    /**
     * 锁分类
     * @param $month
     * @return array
     */
    private function lockPerformanceClass($month){
        try {
            $month = strtotime(date('Y-m',strtotime($month)));
            $ProjectPerformanceClass = new ProjectPerformanceClass();
            $classData = $ProjectPerformanceClass->select();
            $ProjectLockPerformanceClass = new ProjectLockPerformanceClassModel();
            if($classData){
                $data = $classData->toArray();
                foreach($data as $k=>$v){
                    $data[$k]['month'] = $month;
                    if($v['update_time'])  $data[$k]['update_time'] = strtotime($v['update_time']);
                    else $data[$k]['update_time'] = "0";
                    if($v['create_time'])  $data[$k]['create_time'] = strtotime($v['create_time']);
                    else $data[$k]['create_time'] = "0";
                }
                $res = $ProjectLockPerformanceClass->insertAll($data);
                $error = ["status"=>true,"msg"=>"操作成功"];
                return $error;
            }else{
                $error = ["status"=>false,"msg"=>"操作失败"];
                return $error;
            }
        } catch (\Exception $e) {
            $error = ["status"=>false,"msg"=>$e->getMessage(),"code"=>$e->getCode()];
            return $error;
        }
    }

    /**
     * 锁考核标准
     * @param $month
     * @return array
     */
    private function lockPerFormanceContent($month){
        try {
            $month = strtotime(date('Y-m',strtotime($month)));
            $ProjectPerformanceContent = new ProjectPerformanceContent();
            $classData = $ProjectPerformanceContent->select();
            $ProjectLockPerformanceContentModel = new ProjectLockPerformanceContentModel();
            if($classData){
                $data = $classData->toArray();
                foreach($data as $k=>$v){
                    $data[$k]['month'] = $month;
                    if($v['update_time'])  $data[$k]['update_time'] = strtotime($v['update_time']);
                    else $data[$k]['update_time'] = "0";
                    if($v['create_time'])  $data[$k]['create_time'] = strtotime($v['create_time']);
                    else $data[$k]['create_time'] = "0";
                }
                $res = $ProjectLockPerformanceContentModel->insertAll($data);
                $error = ["status"=>true,"msg"=>"操作成功"];
                return $error;
            }else{
                $error = ["status"=>false,"msg"=>"操作失败"];
                return $error;
            }
        } catch (\Exception $e) {
            $error = ["status"=>false,"msg"=>$e->getMessage(),"code"=>$e->getCode()];
            return $error;
        }
    }

    /**
     * 锁考核点
     * @param $month
     * @return array
     */
    private function lockPerFormanceSpot($month){
        try {
            $month = strtotime(date('Y-m',strtotime($month)));
            $ProjectPerformanceSpot = new ProjectPerformanceSpot();
            $classData = $ProjectPerformanceSpot->select();
            $ProjectLockPerformanceSpotModel = new ProjectLockPerformanceSpotModel();
            if($classData){
                $data = $classData->toArray();
                foreach($data as $k=>$v){
                    $data[$k]['month'] = $month;
                    if($v['update_time'])  $data[$k]['update_time'] = strtotime($v['update_time']);
                    else $data[$k]['update_time'] = "0";
                    if($v['create_time'])  $data[$k]['create_time'] = strtotime($v['create_time']);
                    else $data[$k]['create_time'] = "0";
                }
                $res = $ProjectLockPerformanceSpotModel->insertAll($data);
                $error = ["status"=>true,"msg"=>"操作成功"];
                return $error;
            }else{
                $error = ["status"=>false,"msg"=>"操作失败"];
                return $error;
            }
        } catch (\Exception $e) {
            $error = ["status"=>false,"msg"=>$e->getMessage(),"code"=>$e->getCode()];
            return $error;
        }
    }

}
